<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta http-equiv="content-security-policy">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/icons-extra.css" rel="stylesheet" />
		<style>
			.title {
				margin: 20px 15px 10px;
				color: #6d6d72;
				font-size: 15px;
			}

			.oa-contact-cell.mui-table .mui-table-cell {
				padding: 11px 0;
				vertical-align: middle;
			}

			.oa-contact-cell {
				position: relative;
				margin: -11px 0;
			}

			.oa-contact-avatar {
				width: 75px;
			}

			.oa-contact-avatar img {
				border-radius: 50%;
			}

			.oa-contact-content {
				width: 100%;
			}

			.oa-contact-name {
				margin-right: 20px;
			}

			.oa-contact-name,
			oa-contact-position {
				float: left;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a id="menu" class="mui-icon mui-icon-gear mui-pull-right" href="#topPopover"></a>
			<h1 id="title" class="mui-title">追小说看书</h1>
		</header>
		<nav class="mui-bar mui-bar-tab">
			<a id="defaultTab" class="mui-tab-item mui-active" href="bookIndex.html">
				<span class="mui-icon mui-icon-eye"></span>
				<span class="mui-tab-label">追更</span>
			</a>
			<a class="mui-tab-item" href="searchIndex.html">
				<span class="mui-icon mui-icon-search"></span>
				<span class="mui-tab-label">搜索</span>
			</a>
		</nav>

	</body>
	<script src="js/mui.js"></script>
	<script src="js/localdata.js"></script>
	<script>
		//启用双击监听
		mui.init({
			gestureConfig: {
				doubletap: true
			},
		});

		mui.plusReady(function() {
			var subpages = ['bookIndex.html', 'searchIndex.html'];
			var subpage_style = {
				top: '45px',
				bottom: '51px'
			};
			var aniShow = {};
			plus.navigator.setUserAgent(
				"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36", true);
			mui.ajax("https://gitee.com/molunshang/reader/raw/master/js/sites.json", {
				success: function(res) {
					if (res && res.length > 0) {
						store.saveObj("sites.json", res);
					}
				},
				dataType: "json",
				crossDomain: true
			});
			var self = plus.webview.currentWebview();
			for (var i = 0; i < subpages.length; i++) {
				var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
				if (i > 0) {
					sub.hide();
				} else {
					aniShow[subpages[i]] = true;
				}
				self.append(sub);
			}

			//当前激活选项
			var activeTab = subpages[0];
			mui('.mui-bar-tab').on('tap', 'a', function(e) {
				var targetTab = this.getAttribute('href');
				if (targetTab == activeTab) {
					return;
				}
				if (mui.os.ios || aniShow[targetTab]) {
					plus.webview.show(targetTab);
				} else {
					aniShow[targetTab] = true;
					plus.webview.show(targetTab, "fade-in", 300);
				}
				//隐藏当前;
				plus.webview.hide(activeTab);
				var activeView = plus.webview.getWebviewById(activeTab);
				mui.fire(activeView, "onLeave");
				//更改当前活跃的选项卡
				activeTab = targetTab;
			});
		});
	</script>

</html>
